const common = {
    toast: function (text, flag) {
        // 创建一个div标签
        let div = document.createElement('div');
        div.className = 'bg';
        div.innerHTML = `<div class="toast">
    ${flag ? '<i class="iconfont icon-duigouxiao success"></i>' : '<i class="iconfont icon-cuo error"></i>'}

    <div class="msg mt20">${text}</div>
  </div>`;
        console.log(div);
        // 将弹框添加到页面上  appendChild()
        document.body.appendChild(div);

        setTimeout(function () {
            div.remove();
        }, 2000)
    },
    // 底部导航封装
    createFooter(page) {
        let footer = document.createElement('footer');
        footer.className = 'dpflex';

        footer.innerHTML = `<a href="./index.html" class="${page == '首页' ? 'active' : ''}">
      <i class="iconfont icon-31shouye"></i>
      <div class="page">首页</div>
    </a>
    <a href="./sport.html" class="${page == '运动' ? 'active' : ''}">
      <i class="iconfont icon-xindong"></i>
      <div class="page">运动</div>
    </a>
    <a href="./mine.html" class="${page == '我的' ? 'active' : ''}">
      <i class="iconfont icon-wode"></i>
      <div class="page">我的</div>
    </a>`;

        document.body.appendChild(footer);
    }
}
// 将封装公用js挂载到window
window.common = common;